<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="100px">
      <!--进货单编号@keyup.enter.native="handleQuery"-->
      <el-form-item label="进货单编号" prop="innum">
        <el-input v-model="queryParams.innum" placeholder="请输入进货单编号" clearable size="small" />
      </el-form-item>
      <!--进货单编号-->

      <!-- 操作人 -->
      <el-form-item label="操作人" prop="operName">
        <el-input v-model="queryParams.operName" placeholder="请输入操作人" clearable size="small" />
      </el-form-item>
      <!-- 操作人 -->

      <!-- 操作时间 -->
      <el-form-item label="操作时间" prop="operTime">
        <el-input v-model="queryParams.operTime" placeholder="请输入操作操作时间" clearable size="small" />
      </el-form-item>
      <!-- 操作时间 -->
    </el-form>

    <!-- 供应商 -->
    <el-form
      :model="queryParams1"
      ref="queryForm"
      :inline="true"
      label-width="100px"
      style="position: relative;top:-10px;"
    >
      <el-form-item label="供应商" prop="supplierName">
        <el-select
          style="width:200px;"
          v-model="form.name"
          @change="handleBrandChange"
          placeholder="请选择商品"
        >
          <el-option
            v-for="item in goodsOptions"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          ></el-option>
        </el-select>
      </el-form-item>

      <!-- 审核状态 -->
      <el-form-item label="审核状态" prop="operName">
        <el-radio-group v-model="form.operName">
          <el-radio :label="1">已审核</el-radio>
          <el-radio :label="0">未审核</el-radio>
        </el-radio-group>
      </el-form-item>
      <!-- 审核状态 -->
    </el-form>
    <!-- 供应商 -->

    <el-row :gutter="10" class="mb8">
      <!--修改 v-hasPermi="['tenant:salesman:edit']"-->
      <el-col :span="1.5">
        <el-button type="success" icon="el-icon-set-up" size="mini" @click="handleUpdate()">保存</el-button>
      </el-col>
      <!--修改-->

      <!-- 审核 v-hasPermi="['tenant:salesman:edit']"-->
      <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-document-checked"
          size="mini"
          @click="handleCheck()"
        >审核</el-button>
      </el-col>
      <!-- 审核 -->

      <!-- 打印 -->
      <el-col :span="1.5">
        <el-button type="warning" icon="el-icon-download" size="mini" @click="handleExport()">导出</el-button>
      </el-col>
      <!-- 打印 -->

      <!--导出v-hasPermi="['system:user:export']"-->
      <el-col :span="1.5">
        <el-button type="info" icon="el-icon-copy-document" size="mini" @click="handleStamp()">打印</el-button>
      </el-col>
      <!--导出-->
    </el-row>

    <!-- 表格 v-loading="loading"-->
    <el-table class="table" :data="list" @selection-change="handleSelectionChange">
      <el-table-column type="selection" align="center"></el-table-column>
      <el-table-column label="商品名称" align="center" prop="productName" />
      <el-table-column label="商品分类名称" align="center" prop="productCategoryName" />
      <el-table-column label="进价" align="center" prop="price">
        <!-- <template slot-scope="scope">
          <el-input  placeholder>{{scope.row.price}}</el-input>
        </template> -->
      </el-table-column>

      <el-table-column label="进货数量" align="center" prop="productCategoryId">
        <!-- <template slot-scope="scope">
          <el-input  placeholder>{{scope.row.productCategoryId}}</el-input>
        </template> -->
      </el-table-column>

      <el-table-column label="操作人姓名" align="center" prop="supplierName">
        <!-- <template slot-scope="scope">
          <el-input  placeholder>{{scope.row.tenant_person}}</el-input>
        </template> -->
      </el-table-column>

      <el-table-column label="操作人时间" align="center" prop="operTime">
        <!-- <template slot-scope="scope">
          <el-input   placeholder>{{scope.row.tenant_time}}</el-input>
        </template> -->
      </el-table-column>

      <el-table-column label="进货单编号" align="center" prop="innum" />

      <el-table-column label="商品国标码" align="center" prop="productSn" />

      <el-table-column label="商品自主码" align="center" prop="shopProductCode">
        <!-- <template slot-scope="scope">
          <el-input  placeholder>{{scope.row.tenant_art}}</el-input>
        </template> -->
      </el-table-column>

      <el-table-column label="商品助记码" align="center" prop="productHelpCode">
        <!-- <template slot-scope="scope">
          <el-input  placeholder>{{scope.row.tenant_note}}</el-input>
        </template> -->
      </el-table-column>

      <!-- 审核状态 -->
      <el-table-column prop="operOrder" label="审核状态">
        <!-- {{scope.row.operName }} -->
        <template slot-scope="scope">
          <el-tag
            :type="tenantMerchantStatusTagType(scope.row.status)"
            disable-transitions
            v-text="tenantMerchantStatusFormat(scope.row.status)"
          ></el-tag>
        </template>
      </el-table-column>
      <!-- 审核状态 -->
    </el-table>
    <!-- 表格 -->
  </div>
</template>

<script>
import {
  fetchList,
  deletePmsSkuIn,
  updatePmsSkuIn,
  createPmsSkuIn,
  Vendor,
  getPmsSkuIn
} from "@/api/prm/pmsSkuIn";
const defaultHelpCategory = {
  name: ""
};
export default {
  data() {
    return {
      // 遮罩层

      // queryParams:Object.assign({}, defaultHelpCategory),
      loading: true,
      // 平台租户表格数据
      list: [],
      queryParams1: {},
      // 查询参数
      queryParams: {
        address: undefined,
        innum: undefined,
        name: undefined,
        operName: undefined,
        operTime: undefined,
        supplierName: undefined
      },
      form: {},
      goodsOptions: null, // 供应商
      Vendor
    };
  },
  created() {
    // this.getList();
    // fetchList().then(response=>{
    //   console.log(response);
    //   // this.queryParams = response.data.records;
    // })

    // if (this.isEdit) {
    //     getPmsSkuIn(this.$route.query.id).then(response => {
    //       console.log('12121')
    //       this.queryParams = response.data;
    //     });
    //   }else{
    //     this.queryParams = Object.assign({},defaultHelpCategory);
    //   }

    getPmsSkuIn(this.$route.query.id).then(response => {
      // console.log(response.response);
      console.log(response);
      this.list = response.data;
      // console.log('12131')
    });

    this.getSelectProductCateList();
  },
  methods: {
    // getList(){
    //   fetchList(this.queryParams).then(response=>{
    //     this.listLoading = false;
    //     this.list = response.data.records;
    //     this.total = response.data.total;
    //     this.totalPage = response.data.pages;
    //     this.pageSize = response.data.size;
    //   })
    // },


    // 供应商
    getSelectProductCateList() {
      Vendor(0, { pageSize: 100, pageNum: 1 }).then(response => {
        // console.log(response);
        this.goodsOptions = response.data.records;
        this.goodsOptions.unshift({ id: 2, name: "无上级分类" });
      });
    },

    getProductAttributeIdList() {
      //获取选中的筛选商品属性
      let goodsOptions = [];
      console.log(goodsOptions);
      for (let i = 0; i < this.filterProductAttrList.length; i++) {
        let item = this.filterProductAttrList[i];
        if (item.value !== null && item.value.length === 2) {
          goodsOptions.push(item.value[1]);
        }
      }
      return goodsOptions;
    },

    // 多选框选中数据
    handleSelectionChange() {},
    // 保存
    handleUpdate() {

    },

    // 审核
    handleCheck() {},

    // 导出
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm("是否确认导出所有数据项?", "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(function() {
          return exportAgent(queryParams);
        })
        .catch(() => {
          console.log("123");
        });
    },

    // 打印
    handleStamp() {},

    // 供应商
    handleBrandChange() {},

    // 表单重置
    reset() {
      this.form = {
        innum: undefined,
        operName: undefined,
        operTime: undefined,
        supplierName: undefined,
        tenant_name: undefined,
        tenant_price: undefined,
        tenant_pricein: undefined
      };
    },

    // 审核状态
    tenantMerchantStatusTagType(status) {
      const tenantMastatus = this.tenantMerchantStatusFormat(status);
      if (tenantMastatus == "待审核") {
        return "primary";
      }
      return "success";
    },
    tenantMerchantStatusFormat(status) {
       if(status==0) return "已审核"
      // return this.selectDictLabel(this.tenantMerchantStatusOptions, mastatus);
    }
  }
};
</script>
<style scoped>
.input{
  border: none;
  height: 10px;
}
tr{
  border: 1px solid red;
}
tr>>>td{
  height: 10px!important;
}
</style>